﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AgendaManager.AgendaService;

namespace AgendaManager
{
    public partial class frmWaiting : Form
    {
        private List<Foto> Fotos = new List<Foto>();
        public frmWaiting()
        {
            InitializeComponent();
        }

        public void SetValues(List<Foto> fotos)
        {
            Fotos = fotos;
        }

        private void frmWaiting_Load(object sender, EventArgs e)
        {
            btnCerrar.Enabled = false;
            lbFotos.Text = string.Format("Subiendo: 0/{0}", Fotos.Count);
        }

        private void btnGuardar_Click(object sender, EventArgs e)
        {
            int i = 1;
            int increment = (int)Math.Round(100 / (decimal)Fotos.Count, 0);

            //lbFotos.Text = string.Format("Subiendo: 0/{0}", Fotos.Count);

            foreach (Foto f in Fotos)
            {
                lbFotos.Text = string.Format("Subiendo: {0}/{1}", i, Fotos.Count);
                ConnectHelper.ws.NuevaFoto(f);
                pbFotos.Increment(increment);
                i++;
            }

            pbFotos.Increment(increment);
            btnGuardar.Enabled = false;
            btnCerrar.Enabled = true;
        }

        private void btnCerrar_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
    }
}
